<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
			<!--
            	作者：779744514@qq.com
            	时间：2015-11-19
            	描述
            -->
            <script >
                var user={extension:801};
                var t;
                var t2='';
                var queue_t='';
                var queinp_t='';
                var Ageinp_t='';
                var start_t='';
                var end_t='';
                var offset=2;
                //var queuenum=[];
            	var queuenum=['630','631','632','635'];
            	//var perPage = 15;
            	var perPage = undefined;
            	var QueuesInp="630";
            	//var QueuesInp=undefined;
            	var AgentsInp="801";
            	//var AgentsInp=undefined;
            	var startDate="2015/11/18";
            	//var startDate=undefined;
            	var endDate="2015/11/18";
            	//var endDate=undefined;
            	if(perPage == undefined){     //每页显示数量未定
                    t = "select count(AcctId) as rows from cdr";
                }else{                          //每页显示数量已定
                    t = "select * from cdr";
                    t2=" order by start desc limit " + offset + "," + perPage;
                }
                if (queuenum.length != 0) {    //管理员在队列中
                    queue_t = " where calleenum in (";
                    queuenum.forEach(function (item) { queue_t += "'" + item + "',"; });
                    queue_t = queue_t.substring(0, queue_t.length - 1);
                    queue_t +=")";                 
                }else{                         //管理员不在队列
                    queue_t=" where dst ='" + user.extension + "'";
                }
                if(QueuesInp!=undefined){  //输入队列号
                    queinp_t=" and  calleenum = '" + QueuesInp + "'";
                }
                if(AgentsInp!=undefined){
                	Ageinp_t=" and  dst = '" + AgentsInp + "'"
                }
                if(startDate!=undefined){
                	start_t= " and start >= '" + startDate + "'";
                }
                if(endDate!=undefined){
                	endDate +=' 23:59:59';
                	end_t=" and start <= '" + endDate + "'";
                }
            	t = t+queue_t+queinp_t+Ageinp_t+start_t+end_t+t2;
            	console.log(t);
            	
            	
            </script>
	</body>
</html>
